<?php
    class CandidatoVagaHistorico extends BaseModel
    {
    	
    	protected $candidatovagahistoricoid;
    	protected $candidatovagaid;
    	protected $statusid;
        protected $observacao;
        protected $dataregistro;
        protected $operadorid;
        
        const tablename = "candidatovagahistorico";
	    const tablekey = "candidatovagahistoricoid";
	    const tablesequence = "candidatovagahistorico_candidatovagahistoricoid_seq";
        
        //TODO: Criar função inserir bloco em transação

	    public function getRequerente(){
	    	
	    	if ( !$this->candidatovagaid )
	    		return NULL;
	    		
	    	$sql = "SELECT operadorid FROM " . $this->getTableName() . " WHERE candidatovagaid = " . $this->candidatovagaid . " ORDER BY dataregistro DESC LIMIT 1 OFFSET 1";
	    	$result = pg_fetch_object( TSqlSelect::customSelect($sql) );
	    	
	    	if ( !$result )
	    		return NULL;
	    	
	    	return new Operador( $result->operadorid );
	    		
	    }
	    
	    public function getStatus()
	    {
	        return new Status($this->statusid);
	    }
	    
    }
?>